<template>
  <el-checkbox-group v-model="value">
    <el-checkbox v-for="item in options" :key="item.value" :label="item.value">
      {{ item.label }}
    </el-checkbox>
  </el-checkbox-group>
</template>
<script setup lang="ts">
  import { useDictStore } from '@/stores/dictStore'
  const emit = defineEmits(['update:modelValue'])
  const options = ref([])
  const dictStore = useDictStore()
  const value = ref([])
  const props = defineProps({
    code: {
      type: String,
      required: true
    }
  })
  onMounted(async () => {
    options.value = await dictStore.getDict(props.code)
  })

  watch(value, (newVal: (string | number)[]) => {
    emit('update:modelValue', newVal)
  })
</script>
<style lang="scss" scoped></style>
